package com.kayb.patterns.creational;

/**
 * @author huangkaibin
 * 优点：解决了工厂方法违背封闭原则的问题
 * @date 2018-08-28
 **/
public class AbstractFactory {

    interface FactoryService {
        FactoryMethod.NameService createNameService();
    }

    static class AlexFactory implements FactoryService {
        @Override
        public FactoryMethod.NameService createNameService() {
            return new FactoryMethod.Alex();
        }
    }

    static class LylyFactory implements FactoryService {
        @Override
        public FactoryMethod.NameService createNameService() {
            return new FactoryMethod.Lyly();
        }
    }

    public static void main(String[] args) {
        FactoryMethod.NameService nameService = new AlexFactory().createNameService();
        nameService.intro();
    }

}
